object work2 {
  def main(args: Array[String]): Unit = {
    class Calculator {
      def calculate(a: Int, b: Int, operator: Char): Any = operator match {
        case '+' => a + b
        case '-' => a - b
        case '*' => a * b
        case '/' => if (b == 0) "Invalid operation" else a / b
        case _ => "Invalid operator"
      }
    }
    val calculator = new Calculator()
      println (calculator.calculate(10,5,'+') )   // 输出15
      println (calculator.calculate(10,5,'-') )   // 输出5
      println (calculator.calculate(10,5,'*') )   //输出50
      println (calculator.calculate(10,5,'/') )   //输出2
      println (calculator.calculate(10,5,'%') )   //输出"Invalid operator
      println (calculator.calculate(10,5,'^') )
  }
}